package com.example.covid19.mapper;

import com.example.covid19.common.Dto.Ctostu;
import com.example.covid19.common.Dto.KnInfoDto;
import com.example.covid19.entity.Administrateur;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author BaiZhengChun
 * @since 2023-03-07
 */
public interface AdministrateurMapper extends BaseMapper<Administrateur> {
    /**
     *
     * @param auid
     * @return没审批的数据
     */
    @Select("SELECT " +
            " student.`name`, " +
            " demander.* " +
            "FROM " +
            " demander " +
            " INNER JOIN " +
            " student " +
            " ON " +
            " demander.studentid = student.studentid " +
            "WHERE " +
            " demander.istrue = 0 AND " +
            " demander.Auid = #{auid} AND " +
            " demander.studentid = student.studentid"
    )
    List<KnInfoDto> qingjiainfo(@Param("auid") String auid);

    /**
     *
     * @param auid
     * @return审批通过的数据
     */
    @Select("SELECT " +
            " student.`name`, " +
            " demander.* " +
            "FROM " +
            " demander " +
            " INNER JOIN " +
            " student " +
            " ON " +
            " demander.studentid = student.studentid " +
            "WHERE " +
            " demander.istrue = 1 AND " +
            " demander.Auid = #{auid} AND " +
            " demander.studentid = student.studentid"
    )
    List<KnInfoDto> sucinfo(@Param("auid") String auid);

    /**
     *
     * @param auid
     * @return审核拒绝的数据
     */
    @Select("SELECT " +
            " student.`name`, " +
            " demander.* " +
            "FROM " +
            " demander " +
            " INNER JOIN " +
            " student " +
            " ON " +
            " demander.studentid = student.studentid " +
            "WHERE " +
            " demander.istrue = 0 AND " +
            " demander.Auid = #{auid} AND " +
            " demander.studentid = student.studentid"
    )
    List<KnInfoDto> errinfo(@Param("auid") String auid);

    /**
     *
     * @param id
     * @return当前管理员管理的学生（没打卡）
     */
    @Select("SELECT " +
            " classes.clname,  " +
            " majeur.majeurname,  " +
            " cravate.rname,  " +
            " administrateur.`name` AS admname,  " +
            " student.`name` " +
            "FROM " +
            " student " +
            " INNER JOIN " +
            " classes " +
            " ON  " +
            " student.ccid = classes.ccid " +
            " INNER JOIN " +
            " majeur " +
            " ON " +
            " classes.mid = majeur.mid " +
            " INNER JOIN " +
            " cravate " +
            " ON " +
            " majeur.xid = cravate.xid " +
            " INNER JOIN " +
            " administrateur " +
            " ON " +
            " cravate.xid = administrateur.xid"+
            " WHERE " +
            " student.istrue = 0 AND " +
            " administrateur.admid = #{id}"
    )
    List<Ctostu> getcheck0(@Param("id")Integer id);
}
